package com.itheima.controller;

import com.itheima.common.R;
import com.itheima.domain.ResourceCategory;
import com.itheima.manager.UmsResourceCategoryManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class UmsResourceCategoryController {
    @Autowired
    UmsResourceCategoryManager umsResourceCategoryManager;

    //查询所有后台资源分类
    @GetMapping("/resourceCategory/listAll")
    public R<List<ResourceCategory>> findAll(){
        return umsResourceCategoryManager.findAll();
    }

    //添加后台资源分类
    @PostMapping("/resourceCategory/create")
    public R<String> saveCategory(@RequestBody ResourceCategory resourceCategory){
        return umsResourceCategoryManager.saveCategory(resourceCategory);
    }

    //根据ID删除后台资源分类
    @PostMapping("/resourceCategory/delete/{id}")
    public R<String> deleteById(@PathVariable Long id){
        return umsResourceCategoryManager.deleteById(id);
    }

    //修改后台资源分类
    @PostMapping("/resourceCategory/update/{id}")
    public R<String> updateById(@PathVariable Long id,@RequestBody ResourceCategory resourceCategory){
        return umsResourceCategoryManager.updateById(resourceCategory);
    }
}
